How to create a user-defined exception class in PHP | PHP program
We will create a user-defined class that inherits the Exception class and then we will throw an exception using the throw keyword.
<?php
class UserException extends Exception
{
}
try
{
$exp = new UserException("User defined exception");
throw $exp;
}
catch(UserException $e)
{
printf("Exception: %s", $e->getMessage());
}
?>


